# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=acpid
pkgver=2.0.34
pkgrel=4
pkgdesc="The ACPI Daemon (acpid) With Netlink Support"
url="https://sourceforge.net/projects/acpid2/"
arch="all"
license="GPL-2.0-or-later"
makedepends="linux-headers"
install="$pkgname.post-deinstall"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://downloads.sourceforge.net/sourceforge/acpid2/acpid-$pkgver.tar.xz
	handler.sh
	power-supply-ac
	lid-closed
	suspend
	anything
	$pkgname.initd
	$pkgname.confd

	lfs64.patch
	"
options="!check"  # no tests provided

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/ \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--docdir=/usr/share/doc/acpid \
		--localstatedir=/var
	make
}

package() {
	make install DESTDIR="$pkgdir"

	cd "$pkgdir"

	install -D -m 755 "$srcdir"/handler.sh -t etc/acpi/
	install -D -m 644 "$srcdir"/anything -t etc/acpi/events/

	install -D -m 755 -t usr/share/acpid/ \
		"$srcdir"/lid-closed \
		"$srcdir"/power-supply-ac \
		"$srcdir"/suspend

	install -D -m 755 "$srcdir"/$pkgname.initd etc/init.d/$pkgname
	install -D -m 644 "$srcdir"/$pkgname.confd etc/conf.d/$pkgname
}

openrc() {
	default_openrc
	replaces="busybox-openrc"  # overwrites /etc/init.d/acpid
}

sha512sums="
2bf92295b55bb44fe83074b3e0c1ae639f63edaeea84b2184ae95b38852be40f380d5413110b8c0fcb2efc2ec01bf4764e1dcb97022fc724bebbfc35c0b63c81  acpid-2.0.34.tar.xz
050c81446ac563d5d4c5d63a3e0b41558d5934427589114dc8b3215b72a1bd5923e0b8812e6d2265a6f53b6b0bcf8d7cc84d8ea6f2993ceea49c3c864c89c42c  handler.sh
2478afa7cc072f84907789bd90d0d85c8a2f450a29a09637d764d665fd5e68ac7dee3a4ef9e183136e5b0745504c52e7357c5cdb172328c7e7318aa77ecd9c52  power-supply-ac
f6df3e75198e779826c187038804ba80e7a445567342ac912ff4e5d894ce936fb9347146c302c7d7c9bbc8b3a0e47aeee9d23a4b297ee37e3938b7310a1b5ad9  lid-closed
8ec95453c21c5801a0864a5a91fd1d714f29d10a50658e93f027a395dcff91cd0e1ea5047ece199131e6205a422ae6f1887b388068630a0579995e3069d6a3bd  suspend
2e04e5c8a428bfc653b4d56f5a2ff4472169a094ed9eee4b02ea88c755848e4803a0edeb054e152516ee50cb67c8c2be2c43e2e9db9dc80b7fcf218b8907ef6c  anything
c647112006486abb469fdb60c2a91699e6922dac8b09642fa70d4341c9029748f99539d5befc8951adf57a6b382cf5a65adfd208bc2f19cab39b680120504e61  acpid.initd
b8f62dc7d5a2d1338936af79b3e7165cc1c652be0be9e7f8eb00d964c1c1ef91767f16e8662eaa77920d914b966ae208c8480e44cb2dca0de4bfed01f302a089  acpid.confd
a2ba48439f94a079a5d9a4295306b1478a2e025ba32c6b45b46b1b718b209966c2cea2c46c08d17a7d627418e602c4de255f652721d4219bf0c3fff5a8607ad7  lfs64.patch
"
